package com.hc.javabasestudyproject.feature.functionalInterface;

import java.sql.SQLOutput;
import java.util.function.Consumer;
import java.util.function.IntConsumer;

/**
 * @Author: huangcheng
 * @CreateTime: 2023-11-22  10:40
 * @Description: 可以用于传入同类型的不同数据,进行消费处理，通常用于指定类型，
 * @Version: 1.0
 */
public class ConsumerInterface {
    public static void method(String name, Consumer<String> consumer) {
        consumer.accept(name);
    }
    public static void main(String[] args) {
        method("asd", new Consumer<String>() {
            @Override
            public void accept(String name) {
                String reName = new StringBuffer(name).reverse().toString();
                System.out.println(reName);
            }
        });

        method("asd", name -> {
            String reName = new StringBuffer(name).reverse().toString();
            System.out.println(reName);
        });

        test(s->{},"123");
        test(s->{},2.4);
    }

    public static <T> void test(Consumer<T> consumer,T string){
        System.out.println(string);
        String str = "";
        consumer.accept(string);
    }
}
